
HStack is Container View which organizes his child Views horizontally next to each other.
You can't have empty HStack.
When adding Views to the Screen you can choose to
● insert into existing HStack
● insert into new HStack
Enclose existing View inside HStack (You can use this either in the Code or Automatic Preview)
Command + Click on the View + Embed in HStack
Syntax
HStack(alignment: .top, spacing: 200)
Parameters
Align children at the top
HStack(alignment: .center)
Align children at the center
HStack(alignment: .bottom)
Align children at the bottom
HStack(alignment: .firstTextBaseline)
Align to the bottom of the first text
HStack(alignment: .lastTextBaseline)
Align to the bottom of the last text
Space between children. Instead of Spacer().
Example
HStack {
Spacer()
Text("First")
Spacer()
Text("Second")
Spacer()
}
Output